<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author: Author: HCZ <huangchengze@etrol.com> 
// +----------------------------------------------------------------------

namespace app\audit\controller;

use app\common\controller\Admin;
use app\audit\controller\api\Apply as ApplyApi;
use app\admin\controller\ajax\Library as LibarayAjax;
/**
 * 危险源管理
 * @package app\rescue
 */
class Apply  extends Admin

{
    
    protected $api;
    protected $property;
    protected $applyPerson;
    
	public function _initialize()
	{
		parent::_initialize();
		if(session('user_auth.id') != 1){
			$this->applyPerson = session('user_auth.id');
		}
		$this->api = new ApplyApi();
		$this->property = new LibarayAjax();
	}
    /**
     * 首页
     * @return Json/View
     */
   	public function index() {
   	  if(IS_AJAX){
   	  	$wfItemList = $this->api->wfItemList($this->applyPerson);
   	  	return $wfItemList;
   	  }
   	  $wftypeList = $this->property->getWorkflowType()->getData();
   	  $this->assign('wftypeList',$wftypeList);
      return $this->fetch();
 	}
 	
 	/**
 	 * 流程详情
 	 * @param string $itemId
 	 */
 	public function process($itemId = null){
 		$processList = $this->api->processList($itemId)->getData();
 		$this->assign('info',$processList['data']);
 		return $this->fetch();
 	}
 	
 	/**
 	 * 查询
 	 * @return Json
 	 */
 	public function search(){
 		if(IS_AJAX){
 			$wfItemList = $this->api->wfItemList($this->applyPerson,input('wftype'));
 			return $wfItemList;
 		}
 	}
}